package cn.ncupyh.arrlist;

import java.util.ArrayList;
        //集合:只能存储引用数据类型,若存储基本数据类型需要包装类
public class Collection {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        ArrayList<Character> chars = new ArrayList<>();
        list.add("zhangsan");
        list.add("lisi");
        list.add("wanger");
        System.out.println(list.size());//表的长度 = 3
        System.out.println(list.get(2));// wanger
        list.add(1,"zhangsan1");//在下表为1的地方插入值
        System.out.println(list);//[zhangsan, zhangsan1, lisi, wanger]
        list.remove(1);//删除下表为x的值
        System.out.println(list);//[zhangsan, lisi, wanger]
        list.set(1,"lisi2");//改变数组中下标为x的值
        System.out.println(list);//[zhangsan, lisi2, wanger]
    }
}
